﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Content;

namespace StateManager
{
    class PauseScreen : GenericMenu
    {
        public PauseScreen()
            : base("Paused")
        {
            MenuItems resumeGameEntry = new MenuItems("Resume Game");
            MenuItems quitGameEntry = new MenuItems("Quit Current Game");

            resumeGameEntry.Selected += resumeGameSelected;
            quitGameEntry.Selected += quitGameSelected;

            MenuEntries.Add(resumeGameEntry);
            MenuEntries.Add(quitGameEntry);
        }

        void resumeGameSelected(object sender, PlayerEventHandler e)
        {
            if (MediaPlayer.Volume < 0.5f)
                MediaPlayer.Volume = 0.5f;

            ExitScreen();
        }

        public override void HandleInput(Input input)
        {
            base.HandleInput(input);
            PlayerIndex pIndex;
            if (input.IsMenuCancel(null, out pIndex))
            {
                if (MediaPlayer.Volume < 0.5f)
                    MediaPlayer.Volume = 0.5f;

                ExitScreen();
            }
        }

        void quitGameSelected(object sender, PlayerEventHandler e)
        {
            string message = "Do you want to quit?";

            ConfirmBox confirm = new ConfirmBox(message);

            confirm.yes += confirmSelectedEvent;
            //LoadScreen.Load(SManager, true, e.PlayerIndex, new BackgroundScreen(), new TitleScreen());
            SManager.AddScreen(confirm, ControllingPlayer);
        }

        void confirmSelectedEvent(object sender, PlayerEventHandler e)
        {
            LoadScreen.Load(SManager, true, null, new BackgroundScreen(), new TitleScreen());
        }



    }
}
